﻿using System;
using System.Collections.Generic;

public enum MSG_COMMON
{
	MSG_COMMON_ID = 0,

	CHECK_RECONNECT,

	ERROR
}

public enum MSG_ROOM
{
    MSG_CHARACTER_ID = 1000,

	ENTER_ROOM,
	EXIT_ROOM,

	GAME_START,
	GAME_SHOW_CARD,
	GAME_OVER,

	SELECT_ADVISER,
	SELECT_BET_PLAYER,
	SELECT_GROUP,
	BET_POINT,
	BET_RESULT,

    MSG_ROOM_END
}

public enum MSG_ERROR
{
	MSG_ERROR_ID = 9000,

	NONE_ERROR,
	UNKNOW_ERROR,
	VERSION_ERROR,

	CONNECT_ERROR,
	GET_DB_FAILD,
	CONNECT_SERVER_FAILD,
	DATA_ERROR,
	NOT_REPEAT_THIS,
	NOT_DO_THIS,

	ENTER_ROOM_FAILD,
	NOT_ENOUGH_POINT,
	BET_FAILD,

    MSG_ERROR_END
}

public class NetMsgError
{
	static NetMsgError	mInstance = new NetMsgError();
	static public NetMsgError Instance()	{ return mInstance; }
	
	Dictionary<uint, string>	mErrors = new Dictionary<uint, string>();
	
	public void Init()
	{
		AddErrorInfo((uint)MSG_ERROR.UNKNOW_ERROR, "未知错误!");
		AddErrorInfo((uint)MSG_ERROR.VERSION_ERROR, "版本不正确! \n 请下载最新版本!");
		AddErrorInfo((uint)MSG_ERROR.CONNECT_ERROR, "连接错误!");
		AddErrorInfo((uint)MSG_ERROR.GET_DB_FAILD, "获取数据失败!");
		AddErrorInfo((uint)MSG_ERROR.CONNECT_SERVER_FAILD, "连接服务器不成功!");
		AddErrorInfo((uint)MSG_ERROR.DATA_ERROR, "提交数据错误!");
		AddErrorInfo((uint)MSG_ERROR.NOT_REPEAT_THIS, "不可以重复此操作!");
		AddErrorInfo((uint)MSG_ERROR.NOT_DO_THIS, "当前不可以此操作!");

		AddErrorInfo((uint)MSG_ERROR.ENTER_ROOM_FAILD, "进入房间失败!");
		AddErrorInfo((uint)MSG_ERROR.NOT_ENOUGH_POINT, "没有足够的点数!");
		AddErrorInfo((uint)MSG_ERROR.BET_FAILD, "下注失败!");

	}

	public string GetError(uint id)
	{
		string tmp;
		mErrors.TryGetValue (id, out tmp);
		return tmp;
	}
	
	public void AddErrorInfo(uint errID, string errDesc)
	{
		if (mErrors.ContainsKey(errID))
			return;
		
		mErrors.Add(errID, errDesc);
	}
}

public class PaymentOrder
{
	public string name = "";
	public string serverId = "";

}

public class GameHelper
{
    public static readonly Random RandomSource = new Random();
}
